home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / lib / perl5 / Unix / Mknod.pm
Encoding:
Perl POD Document  |  2007-12-23  |  4.8 KB  |  159 lines

  1. package Unix::Mknod;
  2.  
  3. use 5.006;
  4. use strict;
  5. use warnings;
  6.  
  7. require Exporter;
  8.  
  9. our @ISA = qw(Exporter);
  10.  
  11. # Items to export into callers namespace by default. Note: do not export
  12. # names by default without a very good reason. Use EXPORT_OK instead.
  13. # Do not simply export all your public functions/methods/constants.
  14.  
  15. # This allows declaration    use Unix::Mknod qw(:all);
  16. # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
  17. # will save memory.
  18. our %EXPORT_TAGS = ( 'all' => [ qw(
  19.     mknod major minor makedev
  20. ) ] );
  21.  
  22. our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} });
  23.  
  24. our @EXPORT = qw(
  25.  
  26. );
  27.  
  28. our $VERSION = '0.04';
  29.  
  30. require XSLoader;
  31. XSLoader::load('Unix::Mknod', $VERSION);
  32.  
  33. 1;
  34. __END__
  35.  
  36. =head1 NAME
  37.  
  38. Unix::Mknod - Perl extension for mknod, major, minor, and makedev
  39.  
  40. =head1 SYNOPSIS
  41.  
  42.  use Unix::Mknod qw(:all);
  43.  use File::stat;
  44.  use Fcntl qw(:mode);
  45.  
  46.  $st=stat('/dev/null');
  47.  $major=major($st->rdev);
  48.  $minor=minor($st->rdev);
  49.  
  50.  mknod('/tmp/special', S_IFCHR|0600, makedev($major,$minor+1));
  51.  
  52. =head1 DESCRIPTION
  53.  
  54. This module allows access to the device routines major()/minor()/makedev()
  55. that may or may not be macros in .h files.    
  56.  
  57. It also allows access to the C<mknod(2)> system call.
  58.  
  59. =head1 FUNCTIONS
  60.  
  61. =over 4
  62.  
  63. =item I<mknod($filename, $mode, $rdev)>
  64.  
  65. Creates a block or character device special file named I<$filename>. 
  66. Must be run as a privileged user, usually I<root>.  Returns 0 on success
  67. and -1 on failure, like C<POSIX::mkfifo> does.
  68.  
  69. =item I<$major = major($rdev)>
  70.  
  71. Returns the major number for the device special file as defined by the 
  72. st_rdev field from the C<stat(3)> call.
  73.  
  74. =item I<$minor = minor($rdev)>
  75.  
  76. Returns the minor number for the device special file as defined by the 
  77. st_rdev field from the C<stat(3)> call.
  78.  
  79. =item I<$rdev = makedev($major, $minor)>
  80.  
  81. Returns the st_rdev number for the device special file from the I<$major>
  82. and I<$minor> numbers.
  83.  
  84. =back
  85.  
  86. =head1 NOTES
  87.  
  88. There are 2 other perl modules that implement the C<mknod(2)> system call,
  89. but they have problems working on some platforms.  C<Sys::Mknod> does not
  90. work on AIX because it uses the C<syscall(2)> generic system call which
  91. AIX does not have.  C<Mknod> implements S_IFIFO, which on most platforms
  92. is not implemented in C<mknod(1)>, but rather C<mkfifo(1)> (which is
  93. implemented in POSIX perl module).
  94.  
  95. The perl module C<File::Stat::Bits> also implements major() and minor() (and
  96. a version of makedev() called dev_join).  They are done as a program to
  97. get the bit masks at compile time, but if major() and minor() are 
  98. implemented as sub routines, the arugment could be something as simple
  99. as an index to a lookup table (and thereby having no decernable relation
  100. to its result).
  101.  
  102. =head1 BUGS
  103.  
  104. Running C<make test> as non root will not truly test the functions, as in
  105. most UNIX like OSes, C<mknod(2)> needs to be invoked by a privelaged user, 
  106. usually I<root>.
  107.  
  108. =head1 SEE ALSO
  109.  
  110. C<$ERRNO> or C<$!> for the specific error message.
  111.  
  112. L<File::Stat::Bits>, L<Mknod>, L<POSIX>, L<Sys::Mknod>
  113.  
  114. C<major(9)>, C<minor(9)>, C<mkfifo(1)>, C<mknod(8)>
  115.  
  116. ftp://ftp-dev.cites.uiuc.edu/pub/Unix-Mknod
  117.  
  118. =head1 AUTHOR
  119.  
  120. Jim Pirzyk, E<lt>pirzyk@uiuc.eduE<gt>
  121.  
  122. =head1 COPYRIGHT AND LICENSE
  123.  
  124. Copyright (c) 2005-2008 University of Illinois Board of Trustees
  125. All rights reserved.
  126.  
  127. Developed by: Campus Information Technologies and Educational Services,
  128.               University of Illinois at Urbana-Champaign
  129.  
  130. Permission is hereby granted, free of charge, to any person obtaining
  131. a copy of this software and associated documentation files (the
  132. ``Software''), to deal with the Software without restriction, including
  133. without limitation the rights to use, copy, modify, merge, publish,
  134. distribute, sublicense, and/or sell copies of the Software, and to
  135. permit persons to whom the Software is furnished to do so, subject to
  136. the following conditions:
  137.  
  138. * Redistributions of source code must retain the above copyright
  139.   notice, this list of conditions and the following disclaimers.
  140.  
  141. * Redistributions in binary form must reproduce the above copyright
  142.   notice, this list of conditions and the following disclaimers in the
  143.   documentation and/or other materials provided with the distribution.
  144.  
  145. * Neither the names of Campus Information Technologies and Educational
  146.   Services, University of Illinois at Urbana-Champaign, nor the names
  147.   of its contributors may be used to endorse or promote products derived
  148.   from this Software without specific prior written permission.
  149.  
  150. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
  151. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  152. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  153. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
  154. ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  155. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  156. OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
  157.  
  158. =cut
  159.